<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
</head>
<body>

<h3>Login Page</h3>
<form action="#" method="post">
    <input type="text" id="name"/>
    <input type="password" id="password"/>
    <button type="button" id="dologin" >Login</button>
</form>
<script src="../static/js/jquery.min.js" th:src="@{/js/jquery.min.js}"></script>
<script>
    $(function() {
        //简单登录操作
        $("#dologin").click(function (e) {
            $.ajax({
                type : "POST",
                url : "/login",
                data : {
                    "userName" : $("#name").val(),
                    "password" : $("#password").val()
                },
                dataType : "json",
                success : function(data) {
                    if (data.result == "1") {
                        window.location.href ="/index.html";
                    } else {
                        alert("账号密码不能为空！");
                    }
                }
            });
        });
    });
</script>
</body>
</html>